package com.example.hrms.Controller;

import com.example.hrms.Entity.Medicaldocuments;
import com.example.hrms.Service.MedicaldocumentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/medicaldocuments")
public class MedicaldocumentsController {
    @Autowired
    private MedicaldocumentsService medicaldocumentsService;

    @GetMapping("/All")
    public Map<String, List<Medicaldocuments>> All(){
        Map<String, List<Medicaldocuments>> response = new HashMap<>();
        response.put("MedDoc", medicaldocumentsService.All());
        return response;
    }

    @GetMapping("/find")
    public Map<String, List<Medicaldocuments>> Find(int id) {
        Map<String, List<Medicaldocuments>> response = new HashMap<>();
        response.put("MedDoc", medicaldocumentsService.Find(id));
        return response;
    }

    @RequestMapping("/Add")
    @ResponseBody
    public void AddMedDoc(Medicaldocuments medicaldocuments) {
        medicaldocumentsService.AddMedMoc(medicaldocuments);
    }

    @RequestMapping("Del")
    @ResponseBody
    public void Del(Medicaldocuments medicaldocuments){
        int id = medicaldocuments.getId();
        medicaldocumentsService.Del(id);
    }

    @RequestMapping("Update")
    @ResponseBody
    public void update(Medicaldocuments medicaldocuments){
        System.out.println("-=-=-=-=-="+medicaldocuments);
        medicaldocumentsService.Update(medicaldocuments);
    }
}

